import sqlite3

# 连接到数据库
conn = sqlite3.connect('aichat.db')
cursor = conn.cursor()

# 获取所有表
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cursor.fetchall()

print("数据库中的表:")
for table in tables:
    print(f"- {table[0]}")

# 检查每个表的记录数
print("\n各表的记录数:")
for table in tables:
    table_name = table[0]
    try:
        cursor.execute(f"SELECT COUNT(*) FROM {table_name}")
        count = cursor.fetchone()[0]
        print(f"- {table_name}: {count} 条记录")
    except Exception as e:
        print(f"- {table_name}: 无法获取记录数 ({str(e)})")

conn.close()